let registrationApp = new Vue({
    el:"#registrationApp",
    data:{
        oms_username:"",    // 用户名
        oms_email:"",   // 邮箱
        oms_verification:"",    // 邮箱验证码
        oms_password:"",    // 密码
        oms_confirm:"", // 重新输入密码

        // oms_forgotEmail:"", // 忘记密码邮箱
        message:"", // 错误信息
        hasError:false,    // 是否有错误
    },
    methods:{
        // 用户注册
        register:function () {
            let form=new FormData();
            form.append("username",this.oms_username)
            form.append("email",this.oms_email)
            form.append("verification",this.oms_verification)
            form.append("password",this.oms_password)
            form.append("confirm",this.oms_confirm)
            if(this.oms_password != this.oms_confirm){
                this.message = "确认密码不一致！";
                this.hasError = true;
                return;
            }
            axios({
                method:'post',
                url:'http://localhost:9000/auth/user/api/register',
                data:form
            }).then(function(r) {
                console.log("|"+r.status+"|"+OK+"|");
                if(r.data == "ok"){
                    console.log("用户注册成功！！！！");
                    console.log(r.data);
                    registrationApp.hasError = false;
                    location.href = '/login.html?register';
                }else{
                    console.log(r.data);
                    registrationApp.hasError = true;
                    registrationApp.message = r.data;
                }
            });
        },

        // 检查邮箱验证是否正确
        checkEmail:function () {
            let form=new FormData();
            form.append("oms_email",this.oms_email)

            if (this.oms_email==null){
                this.message = "邮箱填写错误！！！";
                this.hasError = true;
                return;
            }
            axios({
                method:'post',
                url:'http://localhost:9000/auth/user/api/registerCheckEmail',
                data:form
            })

        },

    }
})